package com.kangzhili.nettypush.enums;

import lombok.Getter;

/**
 * WebSocket消息类型枚举
 */
@Getter
public enum MessageCode {
    /**
     * 绑定用户
     */
    BIND(100),
    /**
     * 广播消息
     */
    BROADCAST(101),
    /**
     * 心跳
     */
    HEARTBEAT(103);

    private final int code;

    MessageCode(int code) {
        this.code = code;
    }

    public int getCode() {
        return code;
    }

    /**
     * 通过code获取枚举
     */
    public static MessageCode fromCode(int code) {
        for (MessageCode mc : values()) {
            if (mc.code == code) return mc;
        }
        return null;
    }
} 